package com.shi.yibanjia.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.shi.yibanjia.common.Result;
import com.shi.yibanjia.entity.po.DictData;
import com.shi.yibanjia.service.DictDataService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/admin/dict")
public class DictController {

    @Resource
    private DictDataService dictDataService;

    @GetMapping("/orderStatus")
    @Cacheable(value = "yibanjia:dict", key = "'orderStatus'")
    public Result getOrderStatus() {
        List<DictData> list = dictDataService.list(new LambdaQueryWrapper<DictData>()
                .eq(DictData::getTypeId, 2)
                .orderByAsc(DictData::getSortProp));
        return Result.ok(list);
    }
}
